import java.io.*;
import java.util.*;
import java.util.regex.*;

public class ExtractRoomIds {
    public static void main(String[] args) {
        // 文件路径
        String filePath = "C:\\Users\\Administrator\\Desktop\\数据恢复\\combined.log";

        // 用于存储唯一的 roomId
        Set<String> roomIds = new HashSet<>();

        // 正则表达式用于匹配 roomId= 后的数字
        String regex = "roomId=(\\d+)";

        // 编译正则表达式
        Pattern pattern = Pattern.compile(regex);

        // 读取文件
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;

            // 按行读取文件
            while ((line = reader.readLine()) != null) {
                Matcher matcher = pattern.matcher(line);

                // 如果匹配成功，则提取数字并添加到 Set 中
                while (matcher.find()) {
                    roomIds.add(matcher.group(1));
                }
            }

            // 打印去重后的 roomId
            System.out.println("Unique roomIds found:");
            for (String roomId : roomIds) {
                System.out.println(roomId);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
